<?php
require_once '../../Lib/main.php';
$id = null;
$name = null;
$orderIndex = null;
$deleteFLg = '1';

if (isset($_REQUEST['id']) && trim($_REQUEST['id']) !== '') {
	$id = $_REQUEST['id'];
}

if (isset($_REQUEST['name']) && trim($_REQUEST['name']) !== '') {
	$name = $_REQUEST['name'];
}

if (isset($_REQUEST['orderIndex']) && trim($_REQUEST['orderIndex']) !== '') {
	$orderIndex = $_REQUEST['orderIndex'];
}

if (isset($_REQUEST['deleteFLg']) && trim($_REQUEST['deleteFLg']) !== '') {
	$deleteFLg = $_REQUEST['deleteFLg'];
}

$cateDao = new  Dao_CategoryDAO();
$category = new Model_Category(array());
$category->setId($id);
$category->setName($name);
$category->setOrderIndex($orderIndex);
$category->setDeleteFlg($deleteFLg);
$success = $cateDao->insertOrUpdate($category);

$url = '';
if($success) {
	$url = getUrlAdmin("success.php", "rep=listcategory.php");
} else {
	$url = getUrlAdmin("error.php", "rep=listcategory.php");
}

//header('Location: ../'.$url);
?>
<script type="text/javascript" src="../js/custom.js"></script>
<script type="text/javascript">
 	goTo('../<?php echo $url;?>');
</script>